home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #include "parse.h"
- #include <stdio.h>
- #include <unistd.h>
- #include <midi.h>
- #include <midiio.h>
-
- void noteon(MIevent ev, void*, int)
- {
- MImessage m = MESSAGE(ev);
-
- printf("note on: %d: [0x%x, 0x%x]\n", m.channel(), m.byte1(), m.byte2());
- }
-
- void noteoff(MIevent ev, void*, int)
- {
- MImessage m = MESSAGE(ev);
-
- printf("note off: %d: [0x%x, 0x%x]\n", m.channel(), m.byte1(), m.byte2());
- }
-
- void control(MIevent ev, void*, int)
- {
- MImessage m = MESSAGE(ev);
-
- printf("control: %d: [0x%x, 0x%x]\n", m.channel(), m.byte1(), m.byte2());
- }
-
- void pressure(MIevent ev, void*, int)
- {
- MImessage m = MESSAGE(ev);
-
- printf("pressure: %d: [0x%x, 0x%x]\n", m.channel(), m.byte1(), m.byte2());
- }
-
-
- main()
- {
- miParser p;
- MIport port;
- MIevent e;
- MIconfig c;
- u_int pbuf[2];
-
- pbuf[0] = MI_STAMPING;
- pbuf[1] = MIRELSTAMP;
- c.setparams(pbuf,2);
-
- p.changeCallBack(MIDI_NoteOn, (miCallBack) noteon, 0, 0);
- p.changeCallBack(MIDI_NoteOff, (miCallBack) noteoff, 0, 0);
- p.changeCallBack(MIDI_ControlChange, (miCallBack) control, 0, 0);
- p.changeCallBack(MIDI_ChannelPressure, (miCallBack) pressure, 0, 0);
-
- if (port.open("rw", &c) < 0) {
- exit(-1);
- }
-
- port.setstart(0);
-
- while (1) {
- int retval;
-
- if ((retval = port.receive(&e,1)) < 0) // receive 1 event
- {
- exit(-1);
- }
-
- p.Parse(e);
-
- if (retval > 0)
- retval = port.send(&e, retval);
- }
- }
-